#include<bits/stdc++.h>
using namespace std;

vector<complex<double>> generatrComplexWave(int size,double freq)
{
	vector<complex<double>> wave(size);
	for(int i=0;i<size;i++)
	{
		double phase = 2*M_PI *freq*i/size;
		wave[i]=complex<double>(cos(phase),sin(phase));
	}
	return wave;
}
void compp(const vector<complex<double>>& signal)
{
	int  N=signal.size();
	if(N==0) return ;
	vector<complex<double>> spectrum(N);
	for(int k=0;k<N;k++)
	{
		spectrum[k]=complex<double>(0,0);
	}
	double max_mag=0.0;
	for(auto&val:spectrum)
	{
		double mag=abs(val);
		if(mag>max_mag)
		{
			max_mag=mag;
		}
	}
	
}
const int N=1010;

	vector<complex<double>> mapp = generatrComplexWave(1<<2,0.1);


int main()
{
	int n,m,q;
	cin >> n >> m >> q;
	vector<string> g(m);
	for(int i=0;i<m;i++)
	{
		cin >> g[i];
	}
	vector<pair<int,int>> p[4];
	vector<complex<double>> d;
	d=mapp;
	compp(d);
	for(int i=0;i<m;i++)
	{
		for(int j=0;j<m;j++)
		{
			if(g[i][j]=='#')
			{
				//cout<<"debug"<<endl;
				p[0].push_back({i,j});
				p[1].push_back({j,m-1-j});
				p[2].push_back({m-1-i,m-1-j});
				p[3].push_back({m-1-j,i});
			}
			
		}
	}
	vector<vector<int>> a(n,vector<int>(n));
	vector<complex<double>> wave = generatrComplexWave(1<<3,0.25);
	compp(wave);
	int r=0;
	while(q--)
	{
		int opt;
		cin >> opt;
		if(opt==1)
		{
			r=(r+1)&3;
		}
		else {
			int x,y;cin >> x >> y;
			x=x-1,y=y-1;
			for(auto& t:p[r]) {
				a[x+t.first][y+t.second]++;
			}
		}
	}
	wave = generatrComplexWave(1<<3,0.25);
	compp(wave);
	for(int i=0;i<n;i++)
	{
		for(int j=0;j<n;j++)
		{
			
			cout<<a[i][j]<<" ";
		}
		if(i!=n-1)cout<<endl;
	}
	return 0;
}
